package com.shoppingmall.mapper;

import com.shoppingmall.commons.Result;
import com.shoppingmall.model.User;
import com.shoppingmall.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {
@Select("select * from tbl_user where user_name=#{username}")
UserInfo getUserByName(String username);

@Insert("insert into tbl_user values(default,#{user_name},#{user_password},#{user_sex},#{user_email},#{user_birthday},#{user_address},0,0)")
    void addUser(UserInfo userInfo);

    @Select("select user_id,user_name,user_email,user_birthday,user_sex,user_address,user_status from tbl_user")
    List<User> getUserList();
    @Update("update tbl_user set user_status=#{user_status} where user_id=#{user_id}")
   void updateStatus(@Param("user_status") int user_status, @Param("user_id") int user_id);

    @Select("select user_id, user_name, user_sex, user_email, user_birthday, user_address from tbl_user where user_id=#{user_id}")
    UserInfo getUser(int user_id);
    @Update("update tbl_user set   user_sex=#{user_sex}, user_email=#{user_email}, user_birthday=#{user_birthday}, user_address=#{user_address} where user_id=#{user_id}")
    void updateUser(UserInfo userInfo);

}
